//将vant area的数据转换成vant级联的数据结构
export function vantAreaToCascader(areaList) {
  const areaMap = {};
  const options: any[] = [];
  Object.entries(areaList.province_list).forEach(([code, province]) => {
    const item = {
      text: province,
      value: code,
      children: [],
    };
    areaMap[code] = item;
    options.push(item);
  });
  Object.entries(areaList.city_list).forEach(([code, city]) => {
    const item = {
      text: city,
      value: code,
      children: [],
    };
    areaMap[code] = item;
    areaMap[+(code + "").slice(0, 2).padEnd(6, "0")].children.push(item);
  });
  Object.entries(areaList.county_list).forEach(([code, county]) => {
    const item = {
      text: county,
      value: code,
    };
    areaMap[+(code + "").slice(0, 4).padEnd(6, "0")].children.push(item);
  });
  return options
}
